require.config({
    baseUrl: "/cdn/editormd/lib/",
    map: {
        '*': {
            'css': '/cdn/css.min.js',
        }
    },
    // 默认自动加载的模块
    deps: [
        "css!/cdn/editormd/lib/codemirror/codemirror.min.css",
        "css!/cdn/editormd/css/editormd.min.css",
    ],
    paths: {
        jquery: "/cdn/bootstrap/jquery.min",
        editormd: "/cdn/editormd/editormd.amd.min",
        marked: "marked.min",
        prettify: "prettify.min",
        raphael: "raphael.min",
        underscore: "underscore.min",
        flowchart: "flowchart.min",
        jqueryflowchart: "jquery.flowchart.min",
        sequenceDiagram: "sequence-diagram.min",
        katex: "katex.min",
    },
    shim: {
        'jquery': {
            exports: "jQuery"
        }
    }
});

require(["jquery", "editormd"], ($, editormd) => {

    new Vue({
        el: "#app",
        mounted() {
            let editor = editormd("test-editor", {
                path: "/cdn/editormd/lib/"
            });

            $(document).bind("keydown", function (e) {
                if (e.ctrlKey && (e.which == 83)) {
                    e.preventDefault();
                    console.log(editor.getValue());
                    return false;
                }
            });

        },
        template: `
        <div style="height:90vh">
            <div id="test-editor">
                <textarea style="display:none;">### 关于 Editor.md
                    **Editor.md** 是一款开源的、可嵌入的 Markdown 在线编辑器（组件），基于 CodeMirror、jQuery 和 Marked 构建。
                </textarea>
            </div>
        <div>
    `
    })
})